import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/core/values/colors.dart';
import 'package:enterprise_v6_app/app/core/values/gaps.dart';
import 'package:enterprise_v6_app/app/modules/application/basic_information/accident_events/accident_events_detail/accident_events_detail_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

///事故事件详情
class AccidentEventsDetailPage extends StatelessWidget {
  AccidentEventsDetailPage({super.key});

  final controller = Get.put(AccidentEventsDetailController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: AppColors.bg_color_grey,
        appBar: CustomAppBar(
          titleText: '事故事件详情',
        ),
        body: GetBuilder(
          init: controller,
          builder: (_) {
            return SingleChildScrollView(
              child: Column(
                children: [
                  _titleBg(),
                  Container(
                    height: 40.w,
                    width: double.infinity,
                    color: const Color(0xFFF4F7FF),
                    alignment: Alignment.centerLeft,
                    padding: EdgeInsets.only(left: 40.w),
                    child: Text(
                      controller.entity.accidentName,
                      style: TextStyle(
                        fontSize: 16.sp,
                      ),
                    ),
                  ),
                  Container(
                    height: 1.w,
                    color: const Color(0xFFDEE5FD),
                  ),
                  Container(
                    color: Colors.white,
                    padding: EdgeInsets.only(left: 40.w, right: 40.w, top: 20.w, bottom: 20.w),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        _rowData('处置状态：', controller.entity.disposalStatusName),
                        AppGaps.vGap12,
                        _rowData('上报状态：', controller.entity.reportingStatusName),
                        AppGaps.vGap12,
                        _rowData('事故编号：', controller.entity.accidentCode),
                        AppGaps.vGap12,
                        _rowData('事故来源：', controller.entity.accidentSourceName),
                        AppGaps.vGap12,
                        _rowData('事故类型：', controller.entity.accidentTypeName),
                        AppGaps.vGap12,
                        _rowData('事故等级：', controller.entity.accidentLevelName),
                        AppGaps.vGap12,
                        _rowData('经度：', controller.entity.longitude),
                        AppGaps.vGap12,
                        _rowData('纬度：', controller.entity.latitude),
                        AppGaps.vGap12,
                        _rowData('死亡人数：', controller.entity.deathNum.toString()),
                        AppGaps.vGap12,
                        _rowData('重伤人数：', controller.entity.seriousInjuryNum.toString()),
                        AppGaps.vGap12,
                        _rowData('轻伤人数：', controller.entity.minorInjuryNum.toString()),
                        AppGaps.vGap12,
                        _rowData('事故概况：', ''),
                        AppGaps.vGap12,
                        Container(
                            alignment: Alignment.topLeft,
                            padding: EdgeInsets.all(12.w),
                            constraints: BoxConstraints(
                              minHeight: 80.w,
                            ),
                            decoration: BoxDecoration(
                              color: const Color(0xffF7F7FB),
                              borderRadius: BorderRadius.all(Radius.circular(8.w)),
                              border: Border.all(width: 1.w, color: const Color(0xffEBEDF0)),
                            ),
                            child: Text(
                              controller.entity.accidentOverview,
                              style: TextStyle(fontSize: 12.sp, fontWeight: FontWeight.w400, color: const Color(0xFF495061)),
                            ))
                      ],
                    ),
                  ),
                ],
              ),
            );
          },
        ));
  }

  /// 标题背景分隔栏
  Widget _titleBg() {
    return Column(
      children: [
        AppGaps.vGap12,
        Container(
          height: 2.w,
          color: const Color(0xFF587DF5),
        ),
      ],
    );
  }

  Widget _rowData(String name, String value, {double? width}) {
    return Row(
      children: [
        SizedBox(
          width: width ?? 110.w,
          child: Text(
            name,
            style: TextStyle(
              fontSize: 12.sp,
              height: 1.2,
              fontWeight: FontWeight.w400,
              color: const Color(0xFF7C7D93),
            ),
          ),
        ),
        Expanded(
          child: Text(
            value,
            style: TextStyle(
              fontSize: 12.sp,
              height: 1.2,
              color: const Color(0xFF495061),
              fontWeight: FontWeight.w400,
            ),
          ),
        )
      ],
    );
  }
}
